package com.hucheng.common.utils;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-25
 * @Description: 支付宝工具类
 **/
@Slf4j
public class AlipayUtils {

    public static AlipayClient getAlipayClient(Map<String,String> map){
        String appId = map.get("app_id");
        String merchantPrivateKey = map.get("merchant_private_key");
        String alipayPublicKey = map.get("alipay_public_key");
        String gatewayUrl = map.get("gateway_url");
        String signType = map.get("sign_type");
        String charset = map.get("charset");
        String format = map.get("format");
        log.info("支付宝参数配置 >>>>>>>> " + map);
        return new DefaultAlipayClient(gatewayUrl, appId, merchantPrivateKey,format, charset, alipayPublicKey, signType);
    }

    public static String getReturnUrl(Map<String,String> map){
        return map.get("return_url");
    }

    public static String getNotifyUrl(Map<String,String> map){
        return map.get("notify_url");
    }

}
